package modelLayer;
import modelLayer.Exceptions.*;

public class Account
{
    private String name;
    private double balance;
    
    public Account( String name , double balance) {
        this.name=name;
        this.balance=balance;
        if (this.balance<0||this.name==null) {
            throw new IllegalArgumentException("Either balance is negative or the name is null");
        }
    }
    
    public String getName() {
        return name;
    }
    
    public double getBalance() {
        return balance;
    }
    
    public void deposit (double amount) {
        balance+=amount;
    }
    
    public void withdraw (double amount) throws BalanceUnderrunException {
        if (amount > balance) {
            throw new BalanceUnderrunException ("Your are trying to withdraw more  money than the balance of the account", balance, amount);
        }
        balance-=amount;
    }
    
}
